package cn.edu.sdu.sol.intake_system.repository;

import cn.edu.sdu.sol.intake_system.model.po.Department;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface DepartmentRepository extends JpaRepository<Department, Integer> {

    @Query(value = "from Department where departmentId=?1")
    Optional<Department> findDepartmentByDepartmentId(Integer departmentId);

    @Query(value = "from Department where station.stationId=?1")
    List<Department> findDepartmentByStationId(Integer stationId);

    @Query(value = "from Department where true")
    List<Department> findAll();

}
